<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script>
    function jo(){
        const x = document.getElementById("jioshu");
        console.log(x.value)
        const y = parseInt(x.value);

        if (isNaN(y)) {
                alert("请输入有效的数字！");
<<<<<<< HEAD
        }
=======
                
        }

>>>>>>> 30ea6bb (text6)
        if(y%2==0){
            alert("偶数");
        }else{
            alert("奇数");
        }
    }
<<<<<<< HEAD
    // 一个年份如果能被4整除但不能被100整除，或者能被400整除，则该年份为闰年
    function year(){
        const y = document.getElementById("runnian");

        const n = parseInt(y.value);

        if(n%4==0 && n%100!=0  || n%400==0){
            alert(n+"年是闰年");
        }else{
            alert(n+"年不是闰年");
        }
    }
    function sum(){
        const sum1 = document.getElementById("sum1");
        const sum2 = document.getElementById("sum2");

        const x = parseInt(sum1.value);
        const y = parseInt(sum2.value);
        const ans = document.getElementById("ans");
        if(isNaN(x) || isNaN(y)){
           alert("请输入有效数据");
           return ; 
        }
        ans.textContent = x+y;
    }
</script>
<body>
    <h3>判断奇数偶数</h1>
    <input type="number"  id="jioshu" placeholder="请输入整数">
    <button onclick="jo()"> 判断奇偶</button> 
    <br><br><br><br>
    <h3>判断闰年</h3>
    <input type="number" id="runnian" placeholder="请输入年份">
    <button onclick="year()"> 判断是否闰年</button>
    <br><br><br><br>
    <h3>求和</h3>
    <input type="text" id="sum1" placeholder="请输入">
    <br>
    <input type="text" id="sum2" placeholder="请输入">
    <button onclick="sum()">点击求和</button>
    <br>
    计算结果：<p id="ans"></p>
=======
    function year(x){

    }
</script>
<body>
    <input type="number" title="判断奇数偶数" id="jioshu" placeholder="请输入整数">
    <button onclick="jo()"> 判断奇偶</button> 
    <br>
    
>>>>>>> 30ea6bb (text6)
</body>
</html>